
const dev_host = 'https://xsg.youliroam.cn'; // 开发环境域名
const product_host = 'https://www.3things.cn'; // 生产环境域名
const $IMGBASEURL = `https://xiaosongguo.oss-cn-beijing.aliyuncs.com/xcx/image` 
var is_dev =  1  // 0:生产环境 1:开发环境
var baseUrl = '';
if(is_dev == 1){
    baseUrl = dev_host
}else{
    baseUrl = product_host
}


var teamInfo_api ='/api/v1/66d719e50b47f';
var rankingList_api ='/api/v1/66d993d34d02c';


function postRequest(api, data) {
    return new Promise((resolve, reject) => {
        $.ajax({
            type: "POST",
            url: `${baseUrl}${api}`,
            data: JSON.stringify(data),
            contentType: "application/json",
            dataType: "json",
            success: function(response) {
                if (response && response.code == 1) {
                    resolve(response);
                } else {
                    reject(response);
                }
            },
            error: function(err) {
                console.error("错误: " + err.Errmsg);
                reject(err);
            }
        });
    });
}



function request( api,params ){
    return new Promise((resolve,reject)=>{
        $.ajax({
            type:"GET",
            url:`${baseUrl}${api}?${encodeSearchParams(params)}` ,
            dataType:"json",
            success:function(data){
                if(data && data.Status == 0){
                    resolve(data)
                }else {
                    reject(data)
                }
            },
            error:function(err){
                console.error("Error: "+err.Errmsg);
            }
        });
    })

}

function getUrlParameter(name) {
    name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
    var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
    var results = regex.exec(location.search);
    return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
